
<?php
$book =[
    ["id"=>1,"auhtor"=>"zhangsn","bookname"=>"html5","price"=>"34"],
    ["id"=>2,"auhtor"=>"lisi","bookname"=>"css","price"=>"69"],
    ["id"=>3,"auhtor"=>"wangwu","bookname"=>"php","price"=>"77"],
];
if(!empty($_POST['name'])){
    $auhtorname = $_POST['name'];
    $book = array_filter($book,function($v) use ($auhtorname){
        return $v['auhtor'] == $auhtorname;
    });
    
}

if(!empty($_POST['price'])){
    $idprice = $_POST['price'];
    $book = array_filter($book,function($v) use ($idprice){
        return $v['price'] == $idprice;
    });
}

if(!empty($_POST['min'])&&!empty($_POST['max'])){
    $min = $_POST['min'];
    $max = $_POST['max'];
    $book = array_filter($book,function($v) use ($min,$max){
        return $v['price'] >= $min&&$v['price']<=$max;
    });
}

?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<form action="" method="post">
            <input type="text" placeholder="请输入作者" name='name'>
            <input type="submit" value="查询">
            <input type="text" placeholder="请输入价格" name='min'>
            <input type="text" placeholder="请输入价格" name='max'>
            <input type="submit" value="查询">
        </form>
			<table border="1px">
                <tr>
                    <td>编号</td>
                    <td>作者</td>
                    <td>书名</td>
                    <td>价格</td>
                </tr>
              <?php
              foreach($book as $value){?>
            <tr>
                <td><?php echo $value['id'];?></td>
                <td><?php echo $value['auhtor'];?></td>
                <td><?php echo $value['bookname'];?></td>
                <td><?php echo $value['price'];?></td>
            </tr>
             
              <?php
               }
              ?>
            </table>

	</body>
</html>

